package com.tem.service.impl;

import com.tem.base.dao.IBaseDao;
import com.tem.domain.User;
import com.tem.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

/**
 * @Author: tiger
 * @Date:2018/4/28
 * @Description:
 */
@Service
@Transactional
public class UserServiceImpl implements IUserService {
    @Autowired
    private IBaseDao<User> iUserDaoImpl;

    @Override
    public List<User> findUsers() {
        List<User> userList = iUserDaoImpl.find("from User");
        return userList;
    }

    @Override
    public User getUserById(Long userId) {
        return iUserDaoImpl.getById(User.class,userId);
    }

    @Override
    public void addUser(User user) {
        iUserDaoImpl.save(user);
    }

    @Override
    public void updateById(User user) {
        User user1 = iUserDaoImpl.getById(User.class, user.getId());
        user1.setUsername(user.getUsername());
    }
}
